package com.cskaoyan.market.controller;/*
 *文件名: WxCollectController
 *创建者:wxin
 *创建时间:2024/5/20 21:06
 */

import com.cskaoyan.market.db.domain.MarketCollect;
import com.cskaoyan.market.db.domain.MarketGoods;
import com.cskaoyan.market.service.WxCollectService;
import com.cskaoyan.market.util.ResponseUtil;
import com.cskaoyan.market.vo.CollectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wx/collect")
public class WxCollectController {

    @Autowired
    private WxCollectService wxCollectService;


    @GetMapping("list")
    public Object list(Integer type, Integer page, Integer limit) {
        List<CollectVo> collectList = wxCollectService.list(type, page, limit);
        return ResponseUtil.okList(collectList);
    }

    @PostMapping("addordelete")
    public Object addordelete(@RequestBody Map map) {
        Integer valueId= (Integer) map.get("valueId");
        Integer type= (Integer) map.get("type");

        int res=wxCollectService.addOrDelete(valueId,type);
        if(res<=0){
            return ResponseUtil.fail();
        }
        return ResponseUtil.ok();
    }
}
